const joi = require('joi');

//用户id必需项验证
const id = joi.required()
//用户名验证，要求2-10个汉字，可包含额外的汉字组合
const name = joi.string().pattern(/^[\u4E00-\u9FA5]{2,10}([\u4E00-\u9FA5])(2,10){0,2}$/).required()
//邮箱格式验证，要求必须是有效的邮箱地址
const email = joi.string().email().required()
// 新旧密码研究
const oldPassword = joi.string().pattern(/^(?![0-9]+$)[a-z0-9]{1,50}$/).min(6).max(10).required()
const newPassword = joi.string().pattern(/^(?![0-9]+$)[a-z0-9]{1,50}$/).min(6).max(10).required()

exports.password_limit = {
  body: {
    id,
    oldPassword,
    newPassword,
  }
}

exports.name_limit = {
  body: {
    id,
    name,
  }
}

exports.email_limit = {
  body: {
    id,
    email,
  }
}

exports.forgetPassword_limit = {
  body: {
    id,
    newPassword
  }
}